<template>
    <bi-form ref="form">
        <bi-form-item label="应用名称">
            <bi-input v-model="form.name"  required placeholder="3~50个英文字母,下划线和数字，只能以字母开头" :rule="/^[A-Za-z]{1}[A-Za-z0-9_]{2,49}$/" rule-message="3~50个英文字母,下划线和数字，只能以字母开头" />
        </bi-form-item>
        <bi-form-item label="应用标题">
            <bi-input v-model="form.title" required placeholder="请输入应用标题" />
        </bi-form-item>

        <bi-form-item label="应用类型">
            <bi-radio v-model="form.type"  dir="column" placeholder="应用类型" :option="typeOptions" >

            </bi-radio>
        </bi-form-item>
    </bi-form>
</template>

<script>
export  default{
    dialog:{
        title:'创建应用',
        width:500
    },
    data(){

        let typeOptions = [
            {label:'前台+后台应用',value:'front-admin'},
            //{label:'前台应用',value:'front'},
            {label:'后台应用',value:'admin'}
        ];

        return {
            typeOptions,
            form:{
                name:'',
                title:'',
                type:'front-admin'
            }
        }
    },
    methods:{
        dialogOk(){
            if (this.$refs.form.check()){
                this.$ajax({
                    url:this.$url({action:'create'}),
                    data:{
                        ...this.form
                    },
                    success:()=>{
                        this.dialog.callback();
                        this.$toast('创建成功');
                        this.dialog.close();
                    }
                })
            }

            return false;
        }
    }
}
</script>